<?php
/* @var $this EventCustomerController */
/* @var $model EventCustomer */

$this->breadcrumbs=array(
	Yii::t('EventCustomer','Event Customers')=>array('admin'),
	Yii::t('base','Manage'),
);
Yii::app()->clientScript->registerScript('search', "
$('#search-form form').submit(function(){
	$('#event-customer-grid').yiiGridView('update', {
		data: $(this).serialize()
	});
	return false;
});
");
?>
<div class="row-fluid">
	<div class="span12">
    	<div class="box gradient">
        	<div class="title">
           	<?php //echo CHtml::link(Yii::t('common','Advanced Search'),'#collapseOne',array('class'=>'search-button accordion-toggle collapsed btn btn-mini zyBtn03','data-toggle'=>'collapse','data-parent'=>'#accordion2')); ?>
             <?php //echo CHtml::link(Yii::t('common','Create'), array('create'),array('class'=>'btn btn-small create',));?>              <h3> <i class="icon-sitemap"></i> <span><?php echo Yii::t('EventCustomer','Manage Event Customers') ?></span> </h3>
            </div>
            
			<div class="content"> 
			
 			<!--search start-->
 			
              <?php $this->renderPartial('_search',array(
					'model'=>$model,
				)); ?>
              
            <!--search over-->
            
            <!-- table start -->
<script type="text/javascript">
	function gettype($customerid,$event_id)
	{
	var data=new Array();
	$.post("<?php echo Yii::app()->createUrl('EventCustomer/sendSms'); ?>",{'customerid':$customerid,'event_id':$event_id}, 
		
	 function (data) {
      if (data.indexOf("ok,")>0) {
    	  alert('<?php echo Yii::t('base', 'SMS Send Success!');?>'); 
      }
      else
      {  	 
		alert('<?php echo Yii::t('base', 'SMS Send Fail!');?>');
        }
	});
	}
</script>
<script type="text/javascript">
	function gettype1($customerid,$event_id)
	{var data=new Array();
	$.post("<?php echo Yii::app()->createUrl('EventCustomer/SendInform');?>", {'customerid':$customerid,'event_id':$event_id}, 
		   function (data) {
      if (data.indexOf("ok,")>0) {
       alert('<?php echo Yii::t('base', 'Email Send Success!');?>');
      }
      else
      {
    	  alert('<?php echo Yii::t('base', 'Email Send Fail!');?>');
        }
		});
}
</script>      
<?php $this->widget('application.extensions.zgrid.ZGridView', array(
	'id'=>'event-customer-grid',
	'dataProvider'=>$model->search(),
	'itemsCssClass'=>'responsive table table-striped table-bordered',
	'pager'=>array('class'=>'CLinkPager','hiddenPageCssClass'=>'','firstPageCssClass'=>'first paginate_button','firstPageLabel'=>'First','prevPageLabel' => 'Previous','nextPageLabel' => 'Next','lastPageLabel'=>'Last','htmlOptions'=>array('class'=>'dataTables_paginate paging_full_numbers"'),'header'=>""),
	'pagerCssClass'=>'pagination',
	'cssFile'=>false,
	'template'=>'{items}{summary}{pager}',
	'summaryText'=>'Default Pagination',
	//'filter'=>$model,
	
	'columns'=>array(
		array('name'=>'partner_id','headerHtmlOptions'=>array('style'=>'width:10%'),'value' => 'User::model()->findByPk($data->partner_id)->user_name' ),
		array('name'=>'firstname','headerHtmlOptions'=>array('style'=>'width:10%')),
		array('name'=>'lastname','headerHtmlOptions'=>array('style'=>'width:10%')),
		array('name'=>'emailaddress','headerHtmlOptions'=>array('style'=>'width:10%')),
		array('name'=>'mobile','headerHtmlOptions'=>array('style'=>'width:10%')),
			/*
		array (
				'name' => 'award_address',
				'value' => 'Event::model()->getAddressLists($data->award_address,$data->partner_id)',
				'visible' => Yii::app ()->user->level () == 1 
				),
			*/
		array('name'=>'award_address_id','headerHtmlOptions'=>array('style'=>'width:10%')),
		array('name'=>'winning_status','headerHtmlOptions'=>array('style'=>'width:10%'),'value' => 'EventCustomer::model()->switchStatus($data->winning_status)' ),
		array('name'=>'sms_status','headerHtmlOptions'=>array('style'=>'width:10%'),'value' => 'EventCustomer::model()->SmsSwitchStatus($data->sms_status)'),
		
		array(
			'class'=>'CButtonColumn',
			'header' => Yii::t ( 'common', 'Operater' ),
			'template'=>'{view} {update} {delete}',
			'headerHtmlOptions'=>array('style'=>'width:10%'),
	    	'buttons'=>array (
		        'update'=> array(
		            'label'=>'<i class="gicon-edit"></i>',
		            'imageUrl'=>0,
		            'options'=>array( 'class'=>'btn btn-small','rel'=>'tooltip','data-placement'=>'left','title'=>Yii::t('common','Update')),
		        ),
		        'view'=>array(
		            'label'=>'<i class="gicon-eye-open"></i>',
		            'imageUrl'=>0,
		            'options'=>array('class'=>'btn btn-small','rel'=>'tooltip','data-placement'=>'left','title'=>Yii::t('common','View')),
		        ),
		        'delete'=>array(
		            'label'=>'<i class="gicon-remove icon-white"></i>',
		            'imageUrl'=>0,
		             'options'=>array( 'class'=>'btn btn-inverse btn-small','rel'=>'tooltip','data-placement'=>'left','title'=>Yii::t('common','Delete')),
		        ),
		     ),		     
	    ),
	    
				array (
						'class' => 'CButtonColumn',
						'header' => Yii::t ( 'base', 'Resend SMS' ),
						
						'template' => '{Winner Reminder}{Prize Code}',
						
						'buttons' => array (
								'Winner Reminder' => array (
										'label' => Yii::t ( 'base', 'Winner Reminder' ),
										'url' => '"javascript:gettype1(\"".$data->customer_id."\",\"".$data->event_id."\");"',
										'options' => array (
												'class' => 'btn btn-small' 
										),
										'visible' => '$data->winning_status==1' 
								),
								'Prize Code' => array (
										'label' => Yii::t ( 'base', 'Prize Code' ),										
										'options' => array (
												'class' => 'btn btn-small'),
										'url' => '"javascript:gettype(\"".$data->customer_id."\",\"".$data->event_id."\");"',
										'visible' => '$data->winning_status==1' 
								),
								'Export' => array (
										'label' => Yii::t ( 'base', 'Export' ),
										'url' => 'yii::app()->createUrl("/SurveyUser/export",array("id"=>$data->customer_id)) ',
										'options' => array (
												'class' => 'btn btn-small' 
										), 
								), 
						)
						 
				)
	),
)); ?>
					<!--table over -->
			</div><!--//content-->
		</div><!--//box-->
	</div><!--//span12-->
</div><!--//row-fluid-->
